package com.hhxy.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("张三");
        list.add("钱七");
        list.add("王八");
        Stream<String> listStream = list.stream().filter(s->s.startsWith("王"));
//        List<String> wangList = listStream.collect(Collectors.toList());
//        Set<String> wangSet = listStream.collect(Collectors.toSet());
//        System.out.println(wangSet);

        String[] st = listStream.toArray(v -> new String[v]);
        System.out.println(Arrays.toString(st));

    }
}
